--- /** * ============================================================ * SVGarden — https://www.svgarden.dev * Author : Simon-Pierre Boucher * Contact: contact@spboucher.ai * File : src/pages/snippet/[slug].astro * Desc : Snippet detail — live preview, customizer, lesson, copy-ready code * ============================================================ */ import Base from '../../layouts/Base.astro'; import LivePreview from '../../components/LivePreview.astro'; import CodeBlock from '../../components/CodeBlock.astro'; import Customizer from '../../components/Customizer.astro'; import SnippetCard from '../../components/SnippetCard.astro'; import { loadSnippets, copyText } from '../../lib/snippets.mjs'; export async function getStaticPaths() { const snippets = await loadSnippets(); return snippets.map((s) => ({ params: { slug: s.slug }, props: { snippet: s } })); } const { snippet } = Astro.props; const all = await loadSnippets(); const related = all.filter((s) => s.category === snippet.category && s.slug !== snippet.slug).slice(0, 3); const initialCopy = copyText(snippet); // Everything the client-side customizer needs to rewrite preview + code + clipboard. const island = { header: snippet.header, rawCode: snippet.code, slug: snippet.slug, vars: snippet.customizable.map((c) => ({ name: c.var, unit: c.unit ?? '', initial: `${c.default}${c.unit ?? ''}`, })), }; ---

Gallery / {snippet.category} / {snippet.title}

{snippet.title}

{snippet.desc}

{snippet.category} {snippet.difficulty} {snippet.tags.map((t) => {t})}
{ snippet.support && (

⚠ Browser support {snippet.support}

) } { snippet.techniques.length > 0 && (

Techniques: {snippet.techniques.join(' · ')}

) }
{snippet.customizable.length > 0 && }
{ related.length > 0 && (

More {snippet.category}

) }